
export default {
  install (Vue, options) {
    this.installBaseComponent(Vue)
  },
  installBaseComponent (Vue) {
    const components = require.context('@/components', true, /index.(js|vue)$/)
    console.log(components.keys())
    components.keys().forEach(item => {
      const component = components(item).default
      if (component.name) {
        Vue.component(component.name, component)
      } else if (component.install || typeof component === 'function') {
        Vue.use(component)
      } else {
        this.installGroupComponent(Vue, component)
      }
    })
  },
  installGroupComponent (Vue, components) {
    Object.keys(components).forEach(key => {
      Vue.component(components[key].name, components[key])
    })
  }
}
